<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>管理系统</title>


<link rel="stylesheet" type="text/css" href="<%=basePath%>extjs_all/resources/css/ext-all.css"></link>
<link rel="stylesheet" type="text/css" href="<%=basePath%>extjs_all/resources/css/file-upload.css"></link>
<script type="text/javascript" src="<%=basePath%>extjs_all/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=basePath%>extjs_all/ext-all.js"></script>
<script type="text/javascript" src="<%=basePath%>extjs_all/FileUploadField.js"></script>
<script type="text/javascript" src="<%=basePath%>extjs_all/source/locale/ext-lang-zh_CN.js"></script>


<script type="text/javascript">
	//获得后台查询出来组成的树的字符串
	var root = <s:property value='root'/>;
	Ext.onReady(function(){	   
		var menu = new Ext.tree.TreePanel({			  
			rootVisible:false,     //隐藏根节点 
            border:true,          //边框 
            animate:true,         //动画效果 
            autoScroll:true,      //自动滚动 
            enableDD:false,       //拖拽节点              
            containerScroll:true, 
            autoScroll:true,
            height:750,         
			root:root,		
			listeners: {
				click:function(node,e){
					//父级菜单点击就返回
					if(node.attributes.url=="#"){
						return;
					}
					gotoTabPage(node.attributes.url,node.text);
               
				
				},//end click func
				load:function(node,e){
					
				}//end load func
			}//end listeners
	 });
		menu.setRootNode(root); 
		var tabPanel = new Ext.TabPanel({
			  id:'mainPanel',
		      activeTab:0,
		      animScroll:true,
			  autoWidth:true,
		      enableTabScroll:true,
		      layoutOnTabChange:true,
		      deferredRender:false,
		      // html:'<img src="/images/bg.jpg"/>',
		      items: [{
		    	  title:"<img align='center' src='<%=basePath%>imgs/application/application_form.png'/>"+'123',
		    	  html:"wewe"
		      }],
			 // bodyStyle:"background-images:/images/bg.jpg",
		      listeners:{
		    	  
			  }    
		    });	
		//Ext.QuickTips.init();	//初始化Ext.QuickTips，以使得tip提示可用
		new Ext.Viewport({
			title:'管理界面',
			layout:'border',
			items:[{
					//Main页面头部分界面
					collapsible:true,	//可拆分？
					html:'<table width=100% ><tr><td align="left" valign="middle" width="100"></td><td valign="middle"><div  class="titleText">GCInventory Management System</div><div ><BR/>国萃花卉   GC  Ltd. Copyright 2011</div></td><td align="right" ><div><b>欢迎您: ${sessionScope.SystemUsers.userName}${sessionScope.Admin.userName}</b> | <a href="/Logout.action">退出</a> | <a href=#>关于</a></div></td></tr></table>',
	                region:'north',
	                height:80
				},{
					//Main页面左边部分界面
					title:"功能菜单",
					region:"west",
					width:200,
					collapsible:true,
					layout:"accordion",
					layoutConfig: {
						animate: true //动作
						},
					items:[{
						title:"菜单面板",
						items:menu
					},{
						title:"其他",
						html:'this is other'
					}]
					
				},{
					//Main页面中间部分界面
					 collapsible: true,
	                id : 'mainContent',
	                region:'center',
					title:'显示面板',
	                items:tabPanel,
					layout:'fit',
	                html:''
				}]
			
		});
	
		
		// pango: 这里用弹出tabPage的方式(如已有,就根据url reload),注意,pageTitle最好指明
		function gotoTabPage(pageUrl,pageTitle){
			pageTitle = "<img align='center' src='<%=basePath%>imgs/application/application_form.png'/>"+pageTitle;
			var mainPanel = Ext.getCmp('mainPanel');//找到整个系统的panel对象
		   	// 如果有同名的panel,就不用新建一个新的,直接在原来的page加载新连接就可,避免打开太多panel
		   	for(var i=0; i<mainPanel.items.length;i++){
	       		if(mainPanel.items.items[i].title==pageTitle){
					mainPanel.setActiveTab(mainPanel.items.items[i]);
					return;
					//先销毁,然后重新打开新的
	               
	          	}
	       }//end for
			
			//窗体数量
			if(mainPanel.items.length>=10){
				alert("最多只能打开10个窗体");
				return;
		   	}
			// 没打开过,开个新的
		   var tabPage = new Ext.Panel({
	            title:pageTitle,
	            closable:true
	        });
			mainPanel.add(tabPage);
			mainPanel.setActiveTab(tabPage);
			tabPage.load({url:pageUrl,scripts:true});
		}
	   
	});
	
	
</script>

</head>



<body>
</body>
</html>